import { defineStore } from "pinia";
import { debounce } from "lodash-es";

export const useAppStore = defineStore("app", {
  state: () => ({
    routeLoading: false,
    loading: false,
    theme: "light",
    size: "default" as "default" | "large" | "small",
  }),
  actions: {
    initApp() {},
    setTokenCheck(tokenCheck: boolean) {
      // setupTokenCheck(tokenCheck);
    },
    setRouteLoading: debounce(function (this: any, isLoading: boolean) {
      console.log("设置路由加载状态：", isLoading);
      this.routeLoading = isLoading;
    }, 300),
    setLoading(loading: boolean) {
      console.log("设置加载状态:", loading);
      this.loading = loading;
    },
  },
});
